{"ast":null,"code":"import _slicedToArray from \"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";\nimport { useForm as useRcForm } from 'rc-field-form';\nimport * as React from 'react';\nimport scrollIntoView from 'scroll-into-view-if-needed';\nimport { getFieldId, toArray } from '../util';\nfunction toNamePathStr(name) {\n  var namePath = toArray(name);\n  return namePath.join('_');\n}\nexport default function useForm(form) {\n  var _useRcForm = useRcForm(),\n    _useRcForm2 = _slicedToArray(_useRcForm, 1),\n    rcForm = _useRcForm2[0];\n  var itemsRef = React.useRef({});\n  var wrapForm = React.useMemo(function () {\n    return form !== null && form !== void 0 ? form : Object.assign(Object.assign({}, rcForm), {\n      __INTERNAL__: {\n        itemRef: function itemRef(name) {\n          return function (node) {\n            var namePathStr = toNamePathStr(name);\n            if (node) {\n              itemsRef.current[namePathStr] = node;\n            } else {\n              delete itemsRef.current[namePathStr];\n            }\n          };\n        }\n      },\n      scrollToField: function scrollToField(name) {\n        var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n        var namePath = toArray(name);\n        var fieldId = getFieldId(namePath, wrapForm.__INTERNAL__.name);\n        var node = fieldId ? document.getElementById(fieldId) : null;\n        if (node) {\n          scrollIntoView(node, Object.assign({\n            scrollMode: 'if-needed',\n            block: 'nearest'\n          }, options));\n        }\n      },\n      getFieldInstance: function getFieldInstance(name) {\n        var namePathStr = toNamePathStr(name);\n        return itemsRef.current[namePathStr];\n      }\n    });\n  }, [form, rcForm]);\n  return [wrapForm];\n}","map":{"version":3,"names":["useForm","useRcForm","React","scrollIntoView","getFieldId","toArray","toNamePathStr","name","namePath","join","form","rcForm","itemsRef","useRef","wrapForm","useMemo","Object","assign","__INTERNAL__","itemRef","node","namePathStr","current","scrollToField","options","arguments","length","undefined","fieldId","document","getElementById","scrollMode","block","getFieldInstance"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/antd/es/form/hooks/useForm.js"],"sourcesContent":["import { useForm as useRcForm } from 'rc-field-form';\nimport * as React from 'react';\nimport scrollIntoView from 'scroll-into-view-if-needed';\nimport { getFieldId, toArray } from '../util';\nfunction toNamePathStr(name) {\n  const namePath = toArray(name);\n  return namePath.join('_');\n}\nexport default function useForm(form) {\n  const [rcForm] = useRcForm();\n  const itemsRef = React.useRef({});\n  const wrapForm = React.useMemo(() => form !== null && form !== void 0 ? form : Object.assign(Object.assign({}, rcForm), {\n    __INTERNAL__: {\n      itemRef: name => node => {\n        const namePathStr = toNamePathStr(name);\n        if (node) {\n          itemsRef.current[namePathStr] = node;\n        } else {\n          delete itemsRef.current[namePathStr];\n        }\n      }\n    },\n    scrollToField: function (name) {\n      let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n      const namePath = toArray(name);\n      const fieldId = getFieldId(namePath, wrapForm.__INTERNAL__.name);\n      const node = fieldId ? document.getElementById(fieldId) : null;\n      if (node) {\n        scrollIntoView(node, Object.assign({\n          scrollMode: 'if-needed',\n          block: 'nearest'\n        }, options));\n      }\n    },\n    getFieldInstance: name => {\n      const namePathStr = toNamePathStr(name);\n      return itemsRef.current[namePathStr];\n    }\n  }), [form, rcForm]);\n  return [wrapForm];\n}"],"mappings":";AAAA,SAASA,OAAO,IAAIC,SAAS,QAAQ,eAAe;AACpD,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,OAAOC,cAAc,MAAM,4BAA4B;AACvD,SAASC,UAAU,EAAEC,OAAO,QAAQ,SAAS;AAC7C,SAASC,aAAa,CAACC,IAAI,EAAE;EAC3B,IAAMC,QAAQ,GAAGH,OAAO,CAACE,IAAI,CAAC;EAC9B,OAAOC,QAAQ,CAACC,IAAI,CAAC,GAAG,CAAC;AAC3B;AACA,eAAe,SAAST,OAAO,CAACU,IAAI,EAAE;EACpC,iBAAiBT,SAAS,EAAE;IAAA;IAArBU,MAAM;EACb,IAAMC,QAAQ,GAAGV,KAAK,CAACW,MAAM,CAAC,CAAC,CAAC,CAAC;EACjC,IAAMC,QAAQ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